<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>JS 與 iOS 互動</title>
</head>
<body>
    <h1>Hello WKWebView</h1>
    
    <button onclick="callLogin()">呼叫 login</button>
    <button onclick="callShowAlert()">呼叫 showAlert</button>
    <button onclick="callLogEvent()">呼叫 logEvent</button>

    <script>
        function callLogin() {
            window.webkit.messageHandlers.login.postMessage({
                username: "user123",
                password: "pass456"
            });
        }

        function callShowAlert() {
            window.webkit.messageHandlers.showAlert.postMessage("這是來自 H5 的提示！");
        }

        function callLogEvent() {
            window.webkit.messageHandlers.logEvent.postMessage({
                event: "button_click",
                timestamp: new Date().toISOString()
            });
        }
    </script>
</body>
</html>
